﻿using Shop.RemoteModel.PageModuleGoods.Model;
using Shop.RemoteModel.SpuGoods;
using Shop.RemoteModel.SpuGoods.Model;
using Shop.StoreGatewayModular.Interface;
using Shop.StoreGatewayModular.Model.ModuleGoods;
using WeDonekRpc.ApiGateway.Attr;
using WeDonekRpc.Client;
using WeDonekRpc.Helper.Validate;
using WeDonekRpc.HttpApiGateway;
using WeDonekRpc.HttpApiGateway.Model;

namespace Shop.StoreGatewayModular.Api
{
    [ApiRouteName("/shop/page/module/goods/{name}")]
    internal class PageModuleGoodsApi : ApiController
    {
        private readonly IModuleGoodsService _Service;

        public PageModuleGoodsApi ( IModuleGoodsService service )
        {
            this._Service = service;
        }
        public void Delete ( long id )
        {
            this._Service.Delete(id);
        }
        public SpuDatum[] GetTops ( SpuGetTopArg obj )
        {
            return _Service.GetTops(obj);
        }
        public PagingResult<SpuDatum> Query ( PagingParam<SpuGetArg> param )
        {
            return _Service.Query(param);
        }
        public Dictionary<long, int> SetSort ( LongParam<int> sort )
        {
            return this._Service.SetSort(sort.Id, sort.Value);
        }
        public void BatchDelete ( long[] ids )
        {
            this._Service.Delete(ids);
        }
        public ModuleGoodsDto[] Gets ( [NumValidate("shop.page.template.module.id.error", 1)] long tModuleId, [LenValidate("shop.page.module.tag.error", 0, 20)] string tag )
        {
            return this._Service.Gets(tModuleId, tag);
        }

        public ModuleGoodsDto[] Sync ( ModuleGoodsAdd add )
        {
            return this._Service.Sync(add);
        }
    }
}
